/*    */ package net.sf.navigator.menu;
/*    */ 
/*    */ import java.util.regex.Pattern;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ 
/*    */ public class RolesPermissionsAdapter
/*    */   implements PermissionsAdapter
/*    */ {
/* 19 */   private Pattern delimiters = Pattern.compile("(?<!\\\\),");
/*    */   private HttpServletRequest request;
/*    */ 
/*    */   public RolesPermissionsAdapter(HttpServletRequest request)
/*    */   {
/* 23 */     this.request = request;
/*    */   }
/*    */ 
/*    */   public boolean isAllowed(MenuComponent menu)
/*    */   {
/* 32 */     if (menu.getRoles() == null) {
/* 33 */       return true;
/*    */     }
/*    */ 
/* 36 */     String[] allowedRoles = this.delimiters.split(menu.getRoles());
/* 37 */     for (int i = 0; i < allowedRoles.length; i++) {
/* 38 */       if (this.request.isUserInRole(allowedRoles[i])) {
/* 39 */         return true;
/*    */       }
/*    */     }
/*    */ 
/* 43 */     return false;
/*    */   }
/*    */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     net.sf.navigator.menu.RolesPermissionsAdapter
 * JD-Core Version:    0.6.2
 */